package com.calf.cn.utils;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;


/**
 * 读取config.properties配置
 * 
 * @author gdl
 *
 */
public class PropertiesUtil {
	private static PropertiesUtil cfg = null;
	private static Properties properties = new Properties();
	static {
		try {
			 InputStream in = PropertiesUtil.class.getResourceAsStream("/sms.properties");
			 //远程配置加载,配置与项目代码分离 
//			InputStream in = new FileInputStream("D:\\wzg\\workspace\\calfQuickenLoansWeb\\WebContent\\WEB-INF\\configuration\\properties\\sms.properties");
			InputStreamReader reader = new InputStreamReader(in, "UTF-8");
			properties.load(reader);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static PropertiesUtil getInstance() {
		synchronized (PropertiesUtil.class) {
			if (cfg == null) {
				cfg = new PropertiesUtil();
			}
		}
		return cfg;
	}
	public static String get(String key) {
		return properties.getProperty(key).trim();
	}
	
	public static void main(String[] args) {
//		ClassLoader classLoader = PropertiesUtil.class.getClassLoader();
//		System.out.println(classLoader);
//		InputStream inputStream = classLoader.getResourceAsStream("sms.properties");
	}
}
